#ifndef FILELIST_H
#define FILELIST_H

#include <sys/types.h>

typedef enum {SORT_BY_NAME, SORT_BY_NAMELEN, SORT_BY_SIZE, SORT_BY_DATE} eSortCriteria;
typedef enum {ASCENDING = 1, DESCENDING = -1} eSortOrder;

typedef struct {
	char name[256];
	size_t namelen;
	off_t size;
	time_t mtime;
} file_t;

typedef struct {
	file_t *records;
	off_t *index;

	size_t size;
	size_t used;

	eSortCriteria sort_criteria;
	eSortOrder sort_order;
} filelist_t;

void filelist_init (filelist_t *filelist, eSortCriteria sort_criteria, eSortOrder sort_order);
void filelist_free (filelist_t *filelist);

int filelist_insert (filelist_t *filelist, const char *name, size_t namelen, off_t size, time_t mtime);

#endif /* FILELIST_H */
